<!-- 系统管理 -->
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: 'channel/notice' }">系统管理</el-breadcrumb-item>
      <el-breadcrumb-item>通知公告管理</el-breadcrumb-item>
    </el-breadcrumb> 
    <!--列表-->
    <el-table size="small" :data="noticeData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%; margin-top: 30px;">
      <el-table-column align="center" type="selection" width="60">
      </el-table-column>
      <el-table-column align="center"  sortable center prop="className" label="标题" width="200">
      </el-table-column>
      <el-table-column align="center" sortable prop="content" label="内容" width="300">
      </el-table-column>
      <el-table-column align="center"  prop="editTime" label="生效时间" width="200">
      </el-table-column>
      <el-table-column align="center" sortable prop="classTeacher" label="发布人" width="200">
      </el-table-column>
      <el-table-column align="center" sortable prop="addTime" label="发布时间" width="200">
        <template slot-scope="scope">
          <div>{{scope.row.editTime}}</div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="228">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleCheck(scope.$index, scope.row)">查看</el-button>
          <el-button size="mini" type="danger" @click="deleteUser(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
  </div>
</template>

<script>
import { deptList, deptSave, deptDelete } from '../../api/userMG'
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      editForm: {
        classID: '',
       className: '',
       classNo: '',
        token: localStorage.getItem('logintoken')
      },
      // rules表单验证
      rules: {
       className: [
          { required: true, message: '请输入部门名称', trigger: 'blur' }
        ],
       classNo: [{ required: true, message: '请输入部门代码', trigger: 'blur' }]
      },
      noticeInline: {
        page: 1,
        limit: 10,
        varLable: '',
        varName: '',
        token: localStorage.getItem('logintoken')
      },
      // 删除部门
      seletedata: {
        ids: '',
        token: localStorage.getItem('logintoken')
      },
      userparm: [], //搜索权限
      noticeData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      }
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  created() {
    this.getdata(this.noticeInline)
  },

  methods: {
    // 获取数据
    getdata(parameter) {
      this.loading = true
      // 模拟数据开始
      let res = {
        code: 0,
        msg: null,
        count: 3,
        data: [
          {
            addTime: "2024年4月1日",
            editTime:'2024年4月1日',
            classID: 2,
            className: '系统维护通知',
            classNo: 'V001',
            content:'系统将于明晚进行维护，届时将暂停服务。',
            classTeacher: 'admin',
            classPeople: 7,
            parentId: 1
          },
          {
            addTime: "2024年3月1日",
            editTime:'2024年3月1日',
            classID: 3,
           className: '手术安排变更通知',
           classNo: 'J002',
           content:'明天第一台手术安排变更，请相关医生护士注意。',
           classTeacher: 'admin',
           classPeople: 10,
            parentId: 1
          },
          {
            addTime: "2024年4月1日",
            editTime:'2024年4月4日',
            classID: 12,
           className: '设备维护通知',
           classNo: 'J003',
           classTeacher: 'admin',
           classPeople: 6,
           content:'手术室B区设备将于明日进行维护，请提前安排。',
            parentId: 1
          },
          {
            addTime: "2024年5月1日",
            editTime:'2024年5月1日',
            classID: 12,
           className: '节假日安排通知',
           classNo: 'J003',
           classTeacher: 'admin',
           classPeople: 6,
           content:'我司将于五一假期期间放假，请提前安排好工作。',
            parentId: 1
          },
         
        ]
      }
      this.loading = false
      this.noticeData = res.data
      this.pageparm.currentPage = this.noticeInline.page
      this.pageparm.pageSize = this.noticeInline.limit
      this.pageparm.total = res.count
      // 测试环境  模拟数据结束  

      /***
       *  正式环境环境 调用接口
       */
      deptList(parameter)
        .then(res => {
          this.loading = false
          if (res.success == false) {
            this.$message({
              type: 'info',
              message: res.msg
            })
          } else {
            this.noticeData = res.data
            // 分页赋值
            this.pageparm.currentPage = this.noticeInline.page
            this.pageparm.pageSize = this.noticeInline.limit
            this.pageparm.total = res.count
          }
        })
        .catch(err => {
          this.loading = false
          this.$message.error('数据加载失败，请稍后再试！')
        })
    },
    // 分页插件事件
    callFather(parm) {
      this.noticeInline.page = parm.currentPage
      this.noticeInline.limit = parm.pageSize
      this.getdata(this.noticeInline)
    },
    // 搜索事件
    search() {
      this.getdata(this.noticeInline)
    },
    //显示编辑界面
    handleCheck: function(index, row) {
      this.$router.push('/channel/notice/check')
      
    },
  
  }
}
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>

 
 